'''
Author: 红色梧桐 940120450@qq.com
Date: 2024-06-08 15:27:16
LastEditors: 红色梧桐 940120450@qq.com
LastEditTime: 2024-06-12 14:28:33
FilePath: \myReader\applications\extends\cacheUtils\memcache.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
import memcache

# 连接到 Memcache 服务器
db = memcache.Client(['127.0.0.1:11211'], debug=0)

def get_info():
    _, data = db.get_stats()[0]
    print(
        f"memcache服务器进程ID:{data['pid']}\n, 服务器已运行秒数:{data['uptime']}\n,"+
        f"服务器当前Unix时间戳:{data['time']}\n, memcache版本:{data['version']}\n,"+
        f"操作系统指针大小:{data['pointer_size']}\n, 当前连接数量:{data['curr_connections']}\n,"+
        f"Memcached运行以来连接总数:{data['total_connections']}\n, Memcached分配的连接结构数量:{data['connection_structures']}\n,"+
        f"get命令请求次数:{data['cmd_get']}\n, set命令请求次数:{data['cmd_set']}\n,"+
        f"flush命令请求次数:{data['cmd_flush']}\n, get命令命中次数:{data['get_hits']}\n,"+
        f"get命令未命中次数:{data['get_misses']}\n, delete命令未命中次数:{data['delete_misses']}\n,"+
        f"delete命令命中次数:{data['delete_hits']}\n, incr命令未命中次数:{data['incr_misses']}\n,"+
        f"incr命令命中次数:{data['incr_hits']}\n, decr命令未命中次数:{data['decr_misses']}\n,"+
        f"decr命令命中次数:{data['decr_hits']}\n, cas命令未命中次数:{data['cas_misses']}\n,"+
        f"cas命令命中次数:{data['cas_hits']}\n, 使用擦拭次数:{data['cas_badval']}\n,"+
        f"认证命令处理的次数:{data['auth_cmds']}\n, 认证失败数目:{data['auth_errors']}\n,"+
        f"读取总字节数:{data['bytes_read']}\n, 发送总字节数:{data['bytes_written']}\n,"+
        f"分配的内存总大小（字节）:{data['limit_maxbytes']}\n, 服务器是否达到过最大连接（0/1）:{data['accepting_conns']}\n,"+
        f"失效的监听数:{data['listen_disabled_num']}\n, 当前线程数:{data['threads']}\n,"+
        f"连接操作主动放弃数目:{data['conn_yields']}\n, 当前存储占用的字节数:{data['bytes']}\n,"+
        f"当前存储的数据总数:{data['curr_items']}\n, 启动以来存储的数据总数:{data['total_items']}\n,"+
        f"LRU释放的对象数目:{data['evictions']}\n, 已过期的数据条目来存储新数据的数目:{data['reclaimed']}\n,"
    )